
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>数据显示与模板语法 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="cycle.html" />
    
    
    <link rel="prev" href="./" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Angular-cli/">
            
                <a href="../Angular-cli/">
            
                    
                    Angular-cli
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Angular-cli/Angular-cli.html">
            
                <a href="../Angular-cli/Angular-cli.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Angular-cli/restMenu.html">
            
                <a href="../Angular-cli/restMenu.html">
            
                    
                    初始结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../architecture/">
            
                <a href="../architecture/">
            
                    
                    架构
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../architecture/mo-kuai.html">
            
                <a href="../architecture/mo-kuai.html">
            
                    
                    模块简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../architecture/component.html">
            
                <a href="../architecture/component.html">
            
                    
                    组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../architecture/Service.html">
            
                <a href="../architecture/Service.html">
            
                    
                    服务与依赖注入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    组件与模板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.4.1" data-path="zu-jian-yu-mo-ban.html">
            
                <a href="zu-jian-yu-mo-ban.html">
            
                    
                    数据显示与模板语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="cycle.html">
            
                <a href="cycle.html">
            
                    
                    生命周期钩子
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="component.html">
            
                <a href="component.html">
            
                    
                    组件交互
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="style.html">
            
                <a href="style.html">
            
                    
                    组件样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="dynamic.html">
            
                <a href="dynamic.html">
            
                    
                    动态组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="directive.html">
            
                <a href="directive.html">
            
                    
                    属性指令与结构指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="pipeAndAnimit.html">
            
                <a href="pipeAndAnimit.html">
            
                    
                    管道与动画
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../router/">
            
                <a href="../router/">
            
                    
                    路由与导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../form/">
            
                <a href="../form/">
            
                    
                    表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../http/">
            
                <a href="../http/">
            
                    
                    请求http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../project/">
            
                <a href="../project/">
            
                    
                    项目解析:结构目录
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >数据显示与模板语法</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x663E;&#x793A;&#x6570;&#x636E;">&#x663E;&#x793A;&#x6570;&#x636E;</h3>
<ul>
<li><p>&#x63D2;&#x503C;&#x8868;&#x8FBE;&#x5F0F; &#x5982; <code>&#x3002;</code></p>
</li>
<li><p>&#x4F7F;&#x7528; ngFor &#x663E;&#x793A;&#x6570;&#x7EC4;&#x5C5E;&#x6027;</p>
</li>
</ul>
<pre><code>  export class AppComponent {
  title = &apos;Tour of Heroes&apos;;
  heroes = [&apos;Windstorm&apos;, &apos;Bombasto&apos;, &apos;Magneta&apos;, &apos;Tornado&apos;];
  myHero = this.heroes[0];
}
</code></pre><p>&#x5728;&#x6A21;&#x677F;&#x4E2D;&#x4F7F;&#x7528; <code>Angular</code>&#x7684; <code>ngFor</code>&#x6307;&#x4EE4;&#x6765;&#x663E;&#x793A; <code>heroes</code>&#x5217;&#x8868;&#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x9879;&#x3002;</p>
<pre><code>template: `
  &lt;h1&gt;&lt;/h1&gt;
  &lt;h2&gt;My favorite hero is: &lt;/h2&gt;
  &lt;p&gt;Heroes:&lt;/p&gt;
  &lt;ul&gt;
    &lt;li *ngFor=&quot;let hero of heroes&quot;&gt;

    &lt;/li&gt;
  &lt;/ul&gt;
`
</code></pre><ul>
<li>&#x901A;&#x8FC7; <code>NgIf</code>&#x8FDB;&#x884C;&#x6761;&#x4EF6;&#x663E;&#x793A;</li>
</ul>
<pre><code>&lt;p *ngIf=&quot;heroes.length &gt; 3&quot;&gt;There are many heroes!&lt;/p&gt;
</code></pre><h3 id="&#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;">&#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;</h3>
<p>&#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x503C;&#x3002; Angular &#x6267;&#x884C;&#x8FD9;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x5E76;&#x628A;&#x5B83;&#x8D4B;&#x503C;&#x7ED9;&#x7ED1;&#x5B9A;&#x76EE;&#x6807;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x4E2A;&#x7ED1;&#x5B9A;&#x76EE;&#x6807;&#x53EF;&#x80FD;&#x662F; HTML &#x5143;&#x7D20;&#x3001;&#x7EC4;&#x4EF6;&#x6216;&#x6307;&#x4EE4;&#x3002;</p>
<p><code>2</code> &#x4E2D;&#x6240;&#x5305;&#x542B;&#x7684;&#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;&#x662F; <code>1 + 1</code>&#x3002;</p>
<p><code>JavaScript</code> &#x4E2D;&#x90A3;&#x4E9B;&#x5177;&#x6709;&#x6216;&#x53EF;&#x80FD;&#x5F15;&#x53D1;&#x526F;&#x4F5C;&#x7528;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x662F;&#x88AB;&#x7981;&#x6B62;&#x7684;&#xFF0C;&#x5305;&#x62EC;&#xFF1A;</p>
<ul>
<li><p>&#x8D4B;&#x503C; <code>(=, +=, -=, ...)</code></p>
</li>
<li><p><code>new</code> &#x8FD0;&#x7B97;&#x7B26;</p>
</li>
<li><p>&#x4F7F;&#x7528; <code>;</code> &#x6216; <code>,</code> &#x7684;&#x94FE;&#x5F0F;&#x8868;&#x8FBE;&#x5F0F;</p>
</li>
<li><p>&#x81EA;&#x589E;&#x548C;&#x81EA;&#x51CF;&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;<code>++</code> &#x548C; <code>--</code></p>
</li>
<li><p>&#x4E0D;&#x652F;&#x6301;&#x4F4D;&#x8FD0;&#x7B97; <code>|</code> &#x548C; <code>&amp;</code></p>
</li>
<li><p>&#x5177;&#x6709;&#x65B0;&#x7684;&#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x6BD4;&#x5982; <code>|&#x3001;?.</code>&#x548C; <code>!</code>&#x3002;</p>
</li>
</ul>
<p>&#x5178;&#x578B;&#x7684;<strong>&#x8868;&#x8FBE;&#x5F0F;&#x4E0A;&#x4E0B;&#x6587;</strong>&#x5C31;&#x662F;&#x8FD9;&#x4E2A;<strong>&#x7EC4;&#x4EF6;&#x5B9E;&#x4F8B;</strong>&#xFF0C;&#x5B83;&#x662F;&#x5404;&#x79CD;&#x7ED1;&#x5B9A;&#x503C;&#x7684;&#x6765;&#x6E90;&#x3002;</p>
<p>&#x8868;&#x8FBE;&#x5F0F;&#x4E2D;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x53D8;&#x91CF;&#x662F;&#x7531;<code>&#x6A21;&#x677F;&#x53D8;&#x91CF;</code>&#x3001;&#x6307;&#x4EE4;&#x7684;<code>&#x4E0A;&#x4E0B;&#x6587;&#x53D8;&#x91CF;</code>&#xFF08;&#x5982;&#x679C;&#x6709;&#xFF09;&#x548C;&#x7EC4;&#x4EF6;&#x7684;&#x6210;&#x5458;&#x53E0;&#x52A0;&#x800C;&#x6210;&#x7684;&#x3002; &#x5982;&#x679C;&#x4F60;&#x8981;&#x5F15;&#x7528;&#x7684;&#x53D8;&#x91CF;&#x540D;&#x5B58;&#x5728;&#x4E8E;&#x4E00;&#x4E2A;&#x4EE5;&#x4E0A;&#x7684;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x90A3;&#x4E48;&#xFF0C;<code>&#x6A21;&#x677F;&#x53D8;&#x91CF;</code>&#x662F;&#x6700;&#x4F18;&#x5148;&#x7684;&#xFF0C;&#x5176;&#x6B21;&#x662F;&#x6307;&#x4EE4;&#x7684;<code>&#x4E0A;&#x4E0B;&#x6587;&#x53D8;&#x91CF;</code>&#xFF0C;&#x6700;&#x540E;&#x662F;<code>&#x7EC4;&#x4EF6;&#x7684;&#x6210;&#x5458;</code>&#x3002;</p>
<p>&#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;&#x5E94;&#x9075;&#x5FAA;&#x4E0B;&#x5217;&#x6307;&#x5357;&#xFF1A;</p>
<ul>
<li><p>&#x6CA1;&#x6709;&#x53EF;&#x89C1;&#x7684;&#x526F;&#x4F5C;&#x7528; &#xFF1A; &#x6A21;&#x677F;&#x8868;&#x8FBE;&#x5F0F;&#x9664;&#x4E86;&#x76EE;&#x6807;&#x5C5E;&#x6027;&#x7684;&#x503C;&#x4EE5;&#x5916;&#xFF0C;&#x4E0D;&#x5E94;&#x8BE5;&#x6539;&#x53D8;&#x5E94;&#x7528;&#x7684;&#x4EFB;&#x4F55;&#x72B6;&#x6001;&#x3002;</p>
</li>
<li><p>&#x6267;&#x884C;&#x8FC5;&#x901F; &#xFF1A; &#x8868;&#x8FBE;&#x5F0F;&#x5E94;&#x8BE5;&#x5FEB;&#x901F;&#x7ED3;&#x675F;&#xFF0C;&#x5426;&#x5219;&#x7528;&#x6237;&#x5C31;&#x4F1A;&#x611F;&#x5230;&#x62D6;&#x6C93;&#xFF0C;</p>
</li>
<li><p>&#x975E;&#x5E38;&#x7B80;&#x5355; &#xFF1A; &#x5E38;&#x89C4;&#x662F;&#x5C5E;&#x6027;&#x540D;&#x6216;&#x65B9;&#x6CD5;&#x8C03;&#x7528;&#x3002;&#x5076;&#x5C14;&#x7684;&#x903B;&#x8F91;&#x53D6;&#x53CD; (!) &#x4E5F;&#x8FD8;&#x51D1;&#x5408;&#x3002; &#x5176;&#x5B83;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5E94;&#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x5B9E;&#x73B0;&#x5E94;&#x7528;&#x548C;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#xFF0C;&#x4F7F;&#x5F00;&#x53D1;&#x548C;&#x6D4B;&#x8BD5;&#x53D8;&#x5F97;&#x66F4;&#x5BB9;&#x6613;&#x3002;</p>
</li>
<li><p>&#x5E42;&#x7B49;&#x6027; &#xFF1A; &#x5E42;&#x7B49;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x5E94;&#x8BE5;&#x603B;&#x662F;&#x8FD4;&#x56DE;&#x5B8C;&#x5168;&#x76F8;&#x540C;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x76F4;&#x5230;&#x67D0;&#x4E2A;&#x4F9D;&#x8D56;&#x503C;&#x53D1;&#x751F;&#x6539;&#x53D8;&#x3002;</p>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="./" class="navigation navigation-prev " aria-label="Previous page: 组件与模板">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="cycle.html" class="navigation navigation-next " aria-label="Next page: 生命周期钩子">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"数据显示与模板语法","level":"1.4.1","depth":2,"next":{"title":"生命周期钩子","level":"1.4.2","depth":2,"path":"comAndtem/cycle.md","ref":"comAndtem/cycle.md","articles":[]},"previous":{"title":"组件与模板","level":"1.4","depth":1,"path":"comAndtem/README.md","ref":"comAndtem/README.md","articles":[{"title":"数据显示与模板语法","level":"1.4.1","depth":2,"path":"comAndtem/zu-jian-yu-mo-ban.md","ref":"comAndtem/zu-jian-yu-mo-ban.md","articles":[]},{"title":"生命周期钩子","level":"1.4.2","depth":2,"path":"comAndtem/cycle.md","ref":"comAndtem/cycle.md","articles":[]},{"title":"组件交互","level":"1.4.3","depth":2,"path":"comAndtem/component.md","ref":"comAndtem/component.md","articles":[]},{"title":"组件样式","level":"1.4.4","depth":2,"path":"comAndtem/style.md","ref":"comAndtem/style.md","articles":[]},{"title":"动态组件","level":"1.4.5","depth":2,"path":"comAndtem/dynamic.md","ref":"comAndtem/dynamic.md","articles":[]},{"title":"属性指令与结构指令","level":"1.4.6","depth":2,"path":"comAndtem/directive.md","ref":"comAndtem/directive.md","articles":[]},{"title":"管道与动画","level":"1.4.7","depth":2,"path":"comAndtem/pipeAndAnimit.md","ref":"comAndtem/pipeAndAnimit.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["fontsettings","sharing","lunr","search","highlight","livereload"],"pluginsConfig":{"fontsettings":{"family":"sans","size":2,"theme":"white"},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"search":{},"highlight":{},"livereload":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"comAndtem/zu-jian-yu-mo-ban.md","mtime":"2018-06-12T07:12:06.439Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-06-29T06:02:19.129Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    

    </body>
</html>

